<template>
  <el-aside width="240px">
    <h1 class="title">
      &nbsp;&nbsp;&nbsp;<i class="el-icon-s-tools"></i> 设备检索
    </h1>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="设备编号">
        <el-input v-model="form.id"></el-input>
      </el-form-item>
      <el-form-item label="设备名称">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="设备状态">
        <el-select v-model="form.status" placeholder="全部状态">
          <template v-if="name">
            <el-option label="未使用" value="STATUS3"></el-option>
            <el-option label="使用中" value="STATUS4"></el-option>
            <el-option label="维修中" value="STATUS5"></el-option>
            <el-option label="报废中" value="STATUS6"></el-option>
          </template>

          <template v-else>
            <el-option label="已审核" value="STATUS2"></el-option>
            <el-option label="未审核" value="STATUS1"></el-option>
          </template>
        </el-select>
      </el-form-item>
      <el-form-item label="设备分类">
        <el-select v-model="form.category" placeholder="全部分类">
          <el-option
            v-for="item in list"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <el-button type="primary" @click="onSubmit" class="btn">查询</el-button>
  </el-aside>
</template>

<script>
export default {
  name: "AsideView",
  props: ["name"],
  data() {
    return {
      form: {
        name: "",
        category: "",
        status: "",
        id: "",
      },
      list: [],
    };
  },
  methods: {
    onSubmit() {
      this.$bus.$emit("search", this.form);
    },
    // 设备分类函数
    async lists() {
      let res = await this.$axios({
        method: "get",
        url: "/category-list",
        data: this.todata,
      });
      this.list = res.data.data;
    },
  },
  mounted() {
    this.lists();
  },
};
</script>

<style lang="less" scoped>
.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: left;
  // line-height: 200px;
  padding-right: 5px;
  .el-input__inner {
    width: 90%;
    height: 30px;
    padding-right: 0;
    padding: 0 5px;
    .el-input__suffix {
      right: 15px;
    }
  }
}
.title {
  font-size: 26px;
  padding: 10px 0;
  color: rgb(207, 204, 30);
}
.btn {
  width: 80%;
  margin: 40px 30px;
}
</style>